<template>
    <div class="WinBox" v-if='isWin'>
        <div class="time-win-box">
            <div class="time-win-head flex flex-align-center">
                <p class="flex-1">修改使用时间</p>
                 <img src="@/assets/img/business/business-close.png" alt="" @click="closeModelFun">
            </div>
            <div class="time-win-cont">
                <p class="dqTime">到期时间<span>{{WinData.use_end_time}}</span></p>
                <p class="dqName">用户名<span>{{WinData.nickname}}</span></p>
                <p class="dqleixin">账户类型<span>{{WinData.member_type}}</span></p>
                <div class="softTime flex  flex-align-center">
                    <p class="soft-time-p">软件使用时间</p>
                    <select @change="ChangeSelect">
                        <option value="1">增加</option>
                        <option value="0">减少</option>
                    </select>
                    <el-input-number size="mini" v-model="num1" @change="handleChange" :min="1" :max="365"></el-input-number>
                    <p>天</p>
                </div>
                <div class="btn-group flex flex-align-center">
                    <div class="qrBtn flex flex-align-center flex-pack-center" @click="onQueren"><p>确认</p></div>
                    <div class="qxBtn flex flex-align-center flex-pack-center" @click="closeModelFun"><p>取消</p></div>
                </div>
            </div>
        </div>
    </div>
</template>
<script>
import https from '@/public/https'
export default {
    data () {
        return {
            num1:1,
            Select:1,
        }
    },
    props: {
        isWin:{
            type: Boolean,
            default: false 
        },
        WinData:{
            type:Object,
            default:{},
        }
    },
    methods: {
        closeModelFun(){
            this.$emit('close');
        },
        handleChange(value) {
            this.num1 = value;
       },
       ChangeSelect(ele){
           this.Select = ele.target.value
       },
       onQueren(){ //确认修改
           let uid = this.$store.state.userInfo.id;
           let id = this.$store.state.liststatus.parent_id;
           let login_status = this.$store.state.liststatus.login_status;
           let _self = this;
           if(this.Select == 0){
                let num2 = -this.num1;
                this.$confirm('确认当前用户使用时间减少['+this.num1+']天', '提示', {
                    confirmButtonText: '确定',
                     cancelButtonText: '取消',
                        type: 'info'
                        }).then(() => {
                        https.post('Chat/postObtainAddUserTime',{uid:uid,id: _self.WinData.uid,time:num2})
                        .then(data => {
                            if(data.status){
                              _self.$toast({
                                message:data.message
                            });
                                 _self.getNetUserList(id,'',login_status);
                                 _self.Select = 1;
                                _self.$emit('close'); 
                            }else{
                                _self.$toast({massge:data.message});
                            }
                        })
                        }).catch(() => {
                        });
            }else{
                this.$confirm('确认当前用户使用时间增加['+this.num1+']天', '提示', {
                    confirmButtonText: '确定',
                     cancelButtonText: '取消',
                        type: 'info'
                        }).then(() => {
                        https.post('Chat/postObtainAddUserTime',{uid:uid,id: _self.WinData.uid,time:_self.num1})
                        .then(data => {
                            if(data.status){
                              _self.$toast({
                                message:data.message
                            });
                                 _self.getNetUserList(id,'',login_status);
                                _self.$emit('close'); 
                            }else{
                                 _self.$toast({
                                        message:data.message
                                    });
                            }
                        })
                        }).catch(() => { 
                        }); 
            } 
       },
       getNetUserList(uid,keyword,login_status){ //获取列表数据
            this.https('chat/postObtainSubordinateUserList',{uid:uid,keyword:keyword,login_status:login_status},'post')
            .then(data => {
                this.$store.commit('setMembershiplist',data.list);
            })
        }
    }
}
</script>
<style lang="less" scoped>
@import url(../../../assets/css/chatroom/modificationtimewin.less);
</style>

